<#include "../common/main_layout.ftl" />

<#macro mainContent>
<section class="content-header">
  <h1>
    Applications
    <small>overview</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href=""><i class="fa fa-home"></i> Home</a></li>
    <li class="active">Applications</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

  <div class="row">
    <div class="col-xs-12">
      <div class="box box-primary">
        <div class="box-header">
          <h3 class="box-title">List of Application</h3>

          <div class="box-tools">
            <div class="input-group" style="width: 200px;">
              <input type="text"
                     name="table_search"
                     class="form-control input-sm pull-right"
                     placeholder="Application name"/>

              <div class="input-group-btn">
                <button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
              </div>
            </div>
          </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body table-responsive no-padding">
          <table class="table table-hover table-striped">
            <thead>
            <tr>
              <th>Application name</th>
              <th>Owner</th>
              <th>Providers</th>
              <th>Consumers</th>
              <th>Depends On</th>
              <th>Used by</th>
            </tr>
            </thead>
            <tbody>
            <#list rows as row>
            <tr>
              <td>${row.name}</td>
              <td>${row.owner} <#if row.organization?exists>[${row.organization}]</#if></td>
              <td>
                <#if row.providerCount gt 0>
                <a href="applications/providers?application=${row.name}"><i class="fa fa-truck"></i> [${row.providerCount}]</a>
                <#else>
                <span class="badge bg-gray">No provider</span>
                </#if>
              </td>
              <td>
                <#if row.consumerCount gt 0>
                <a href="applications/consumers?application=${row.name}"><i class="fa fa-credit-card"></i> [${row.consumerCount}]</a>
                <#else>
                <span class="badge bg-gray">No consumer</span>
                </#if>
              </td>
              <td>
                <#if row.efferentCount gt 0>
                <a href="applications/dependencies?application=${row.name}"><i class="fa fa-level-up"></i> [${row.efferentCount}]</a>
                <#else>
                <span class="badge bg-gray">No dependency</span>
                </#if>
              </td>
              <td>
                <#if row.afferentCount gt 0>
                <a href="applications/dependencies?application=${row.name}&reverse=true"><i class="fa fa-level-down"></i>
                  [${row.afferentCount}]</a>
                <#else>
                <span class="badge bg-gray">No used</span>
                </#if>
              </td>
            </tr>
            </#list>
            </tbody>
          </table>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>
  </div>

</section>
</#macro>

<@doLayout />